feat(comms): per-user chat inbox category (priority / general) - #1037
Open
dylanjeffers wants to merge 1 commit into
Open
feat(comms): per-user chat inbox category (priority / general)#1037dylanjeffers wants to merge 1 commit into
dylanjeffers wants to merge 1 commit into
Conversation
Backs the Priority / General inbox split in the clients. Each user can
file a direct-message chat into a "priority" or "general" inbox; the
choice is private to that user and a chat with no row is uncategorized.
- Migration 0240 adds `user_conversation_preferences`
(user_id, chat_id, category, updated_at), PK (user_id, chat_id).
- New RPC `chat.set_category` { chat_id, category | null }. Validation
checks membership and the enum; writes are guarded by the RPC
timestamp like chat_permissions so a late RPC can't clobber newer state;
null deletes the row.
- `GET /comms/chats` and `GET /comms/chats/:id` return `category` per chat
(null for uncategorized and blasts).
- New `GET /comms/chats/unread_by_category` returns unread-chat counts
split into priority / general / uncategorized, mirroring
`/comms/chats/unread`'s filter.
- sql/01_schema.sql and sql/03_migration_tracker.sql re-dumped via
`make test-schema` (also picks up previously un-dumped 0238/0239).
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Backend for the Priority / General inbox split in the clients. Users can file each direct-message chat into a Priority or General inbox; the choice is private to that user and persists so future messages route to the right tab. A chat with no preference row is uncategorized.
Changes
0240_user_conversation_preferences.sql:user_conversation_preferences (user_id, chat_id, category CHECK IN ('priority','general'), updated_at), PK(user_id, chat_id). Idempotent, wrapped in a transaction.chat.set_category{ chat_id, category: "priority" | "general" | null }: validator checks chat membership and the enum; apply upserts with the RPC timestamp guard (same idiom aschat_permissions), andnulldeletes the row. NewChatCategoryenum andCategoryparam inschema.go.GET /comms/chatsandGET /comms/chats/:chatIdnow return"category"per chat (nullfor uncategorized and for blast pseudo-chats). Both queries LEFT JOIN the new table; thememberssubquery was re-aliased to avoid ambiguity.GET /comms/chats/unread_by_category:{ priority, general, uncategorized }counts of chats withunread_count > 0, mirroring/comms/chats/unread's filter. All three keys are always present.sql/01_schema.sql/sql/03_migration_tracker.sqlre-dumped viamake test-schema. This also picks up drift from 0238/0239 (which were never re-dumped) and a pg_dump header version bump from the local image.clear_user_recordsonly exists in the frozen schema dump, so it does not yet delete from the new table; that needs a separate function migration if wanted.Companion PR
Client side (SDK, store, web and mobile tab UI): AudiusProject/apps#14593. Deploy this first; older clients ignore the new field, and the new client falls back gracefully if the endpoint is missing.
Test plan
go build ./...,go vetclean,gofmtclean on changed filesgo test ./api/comms/...(newTestChatSetCategory: validator accept/reject, apply, timestamp guards, clear)go test ./api/...(newTestPostMutateChatSetCategoryround trip through/comms/mutateassertingcategoryon both GET endpoints and per-user isolation; newTestGetUnreadCountByCategory)categoryandunread_by_categoryresponses🤖 Generated with Claude Code